using UnityEngine;
using System.Collections;

public class Interface  :MonoBehaviour {
	
	private float timer = 60;
	private bool countTime=false;
	GameObject GSMenu;
	GameObject getScore;
	UILabel Res;
	public void resetAll()
	{
		timer = 60;
		ScoreCount.scoreReset ();
	}
	public void SetTime(int second, bool count)
	{
		countTime = count;
		
		timer = second;
	}
	
	void Start()
	{
		resetAll ();
		NGUITools.AddChild(gameObject,(GameObject)Resources.Load("GetScoreMenu"));
			getScore = GameObject.Find ("GetScoreMenu(Clone)");
				getScore.transform.localPosition = new Vector3 (0.0f,20.0f,720.0f);
	if(countTime)
		{
			timer = 1;
			timer += Time.deltaTime;
		}
		else
		{
			timer -= Time.deltaTime;
		}
		Res = GameObject.Find("ResultScore").GetComponent<UILabel>();
	}
	
	void Update()
	{
		if(countTime)
		{
			timer += Time.deltaTime;
		}
		else
		{
			timer -= Time.deltaTime;
		}
		
		var Label = GameObject.Find("ScoreCounter").GetComponent<UILabel>();
		Label.text = System.Convert.ToString(ScoreCount.GetScoreCount());
	
		var Label1 = GameObject.Find("TimeCounter").GetComponent<UILabel>();
		Label1.text = System.Convert.ToInt32(timer).ToString();
		
		if(timer <= 0)
		{
			timer = 60;
			Time.timeScale = 0;
			getScore.transform.localPosition = new Vector3(0.0f,-528.0f,0.0f);
			Res.text = "You score is:  " + System.Convert.ToString(ScoreCount.GetScoreCount());
		}
		
		//var Label2 = GameObject.Find("CC").GetComponent<UILabel>();
		//Label2.text = "X " + ScoreCount.ComboForAmount.ToString();
		
		//var Label3 = GameObject.Find("CForLineC").GetComponent<UILabel>();
		//Label3.text = " X " + ScoreCount.ComboForLineAmount.ToString();
	}
}
